package com.fms.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fms.entity.Product;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ProductMapper extends BaseMapper<Product> {
    @Delete("delete from product where id = #{id}")
    void deleteProductById(String id);
    @Select("SELECT p.* FROM product p, order_detail od WHERE p.id = od.product_id GROUP BY p.id ORDER BY SUM(od.amount) DESC")
    List<Product> getBestSells();
}
